package com.jci.vsd.adapter.enterprise;

import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.TextView;

import com.jci.vsd.R;
import com.warmtel.expandtab.KeyValueBean;

import java.util.List;

/**
 * Created by liqing on 18/7/12.
 */

public class CompanySpinnerAdapter extends BaseAdapter {

    private List<KeyValueBean> mData;
    private Context context;

    public CompanySpinnerAdapter(List<KeyValueBean> mData, Context context) {
        this.mData = mData;
        this.context = context;
    }


    @Override
    public int getCount() {
        return mData.size();
    }

    @Override
    public Object getItem(int position) {
        return mData.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        final ViewHolder viewHolder;
        if(convertView==null){
            convertView=LayoutInflater.from(context).inflate(R.layout.spinner_item,null);
            viewHolder=new ViewHolder();
            viewHolder.textView=(TextView)convertView.findViewById(R.id.tv_spinner);
            convertView.setTag(viewHolder);
        }else {
            viewHolder=(ViewHolder) convertView.getTag();
        }

        viewHolder.textView.setText(mData.get(position).getValue());
        return convertView;

    }


    // class for holding the cached view
    static class ViewHolder {
        TextView textView;

    }
}
